package com.example.jk.controller;

import com.example.jk.entity.JBody;
import com.example.jk.service.JBodyService;
import com.example.jk.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/body")
public class JBodyController {
    @Autowired
    JBodyService jBodyService;
    @GetMapping("/selectPage")
    public Result selectPage(JBody jBody){
        return jBodyService.selectpage(jBody);
    }
    //新增接口
    @PostMapping("/add")
    public Result add(@RequestBody JBody jBody){
        boolean bool = jBodyService.save(jBody);
        return new Result(200,"新增成功",bool);
    }
    //修改
    @PostMapping("/update")
    public Result update(@RequestBody JBody jBody){
        //获取创建时间
        JBody jBody1 = jBodyService.getById(jBody.getId());
        boolean bool = jBodyService.updateById(jBody);
        return new Result(200,"修改成功",bool);
    }
    //删除
    @DeleteMapping("/delete")
    public Result deleteHw(@RequestParam int id){
        boolean bool = jBodyService.removeById(id);
        return new Result(200,"删除成功",bool);
    }

}
